$(function (){

    var accountName = sessionStorage.getItem('accountName'),
        accountIsManager = sessionStorage.getItem('accountIsManager'),
        accountSelectManager = sessionStorage.getItem('accountSelectManager'),


        $bookManagePage = $('#bookManage'),
        $userManagePage = $('#userManage'),
        $login_links = $('.userlogin'),
        $not_login_links = $('.usernotlogin'),
        $welcome_user = $('#accountName'),
        $welcome_visitor = $('#visitor'),

        $user_title = $('#user-title'),
        $manager_title = $('#manager-title'),
        $visitor_title = $('#visitor-title');


    console.log('当前账户用户名: '+accountName+
        '  该用户选择身份是否是管理员: '+accountSelectManager+
        '  该用户真实身份是否是管理员: '+accountIsManager);

    //游客方式登录
    if(accountName === ''||accountName === null || accountName === undefined){
        console.log('游客方式登录');
        $visitor_title.show();
        //隐藏侧边栏的图书和用户管理
        $bookManagePage.hide();
        $userManagePage.hide();
        //顶部导航显示情况
        $login_links.hide();
        $welcome_user.hide();
        //无法点击用户名进入个人账户
        $('#nav-top-selfInfo-link').click(function () {
            confirm('请先登录！');
            $(document).preventDefault();
        })
        //无法访问个人账户




    }else if(accountSelectManager === '0') {//用户登录
        console.log('用户登录');
        $user_title.show();
        //隐藏侧边栏的图书和用户管理
        $bookManagePage.hide();
        $userManagePage.hide();
        //顶部导航显示情况
        $not_login_links.hide();
        $welcome_visitor.hide();
        $welcome_user.text(accountName);

    }else{//管理员登录
        console.log('管理员登录');
        $manager_title.show();
        //顶部导航显示情况
        $not_login_links.hide();
        $welcome_visitor.hide();
        $welcome_user.text(accountName);
    }

    //点击退出按钮
    $('#exit').on('click',function () {
        sessionStorage.clear();
        location.href = 'bookHome';
    })

    //点击个人账户判断是游客则不访问该页面

    // $('#selfInfo').click(function () {
    //     if(accountName === ''||accountName === null || accountName === undefined) {
    //         confirm('请先登录！');
    //         $(document).preventDefault();
    //     }else{
    //         location.href = 'selfInfo';
    //     }
    //
    //
    // })







})